/*
 * @Author: wuzhen
 * @Date: 2019-01-28 16:00:48
 * @LastEditors: wuzhen
 * @LastEditTime: 2019-02-21 10:05:15
 * @Description: 按钮权限
 */
export default {
  bind(el, binding, vnode) {
    let permissionList = vnode.context.$route.meta.permission;
    if (!permissionList) {
      // console.error(
      //   `权限判断不生效。因路由中不包含permission字段，请检查路由表设置。当前路由地址：${
      //     vnode.context.$route.path
      //   }`
      // );
      return;
    }
    if (typeof permissionList !== 'object' || !permissionList.length) {
      // console.error(
      //   `权限判断不生效。因路由中permission字段非数组类型或内容为空，请检查路由表设置。当前路由地址：${
      //     vnode.context.$route.path
      //   }`
      // );
      return;
    }
    if (!permissionList.includes(binding.value)) {
      vnode.context.$nextTick(() => el.parentNode.removeChild(el));
    }
  }
};
